| Visual Basic (Declaration) | |
|---|---|
Public Overloads Function WaitFor( _ ByVal prompts() As String _ ) As String | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Tcp Dim prompts() As String Dim value As String value = instance.WaitFor(prompts) | |
| C++/CLI | |
|---|---|
public: String^ WaitFor( array<String^>^ prompts ) | |
Parameters
- prompts
- Data is read until one of the strings in the array is found.
Return Value
A string containing all data read from the stream.| Exception | Description |
|---|---|
| System.Net.Sockets.SocketException | prompt was not found within the specified period of time. |
| System.InvalidOperationException | Tcp.ReceiveTimeout is 0. |
This method reads from the data stream until one of the specified strings are found or the method times out. Often, it is useful when communicating with a server to be able to read data until one of several tokens is found. For example, during the login operation the server may send a string "login:". You could use the WaitFor method to keep reading until you find "login:", then issue your login command.
This method will block for the amount of time specified in Tcp.ReceiveTimeout. If Tcp.ReceiveTimeout is 0, this method will throw a System.InvalidOperationException. If prompt is not found within the time specified by Tcp.ReceiveTimeout, a System.SocketException is thrown (with the timeout ErrorCode of 10060).
Target Platforms: Microsoft .NET Framework 2.0